def fib(n):
    current = 0
    num1,num2 =0,1
    while current<n:
        num =num1
        num1 , num2 = num2 ,num1+num2
        current +=1
        yield num
    return 'ok'

s =fib(10)


while True:
    try:
        x = next(s)
        print(x)

    except StopIteration as e:
        print('生成器的返回值:%s'%e.value)
        break



